package com.itheima.edu.info.manager.service;

import com.itheima.edu.info.manager.dao.StudentDao;
import com.itheima.edu.info.manager.domin.Student;

public class StudentService {
    private static StudentDao studentDao = new StudentDao();

    //添加学号
    public boolean addStudent(Student student) {
        return studentDao.addStudent(student);
    }

    //判断学号是否存在
    public boolean isExists(String sid) {
        Student[] stus = studentDao.findAllStudent();
        for (int i = 0; i < stus.length; i++) {
            Student stu = stus[i];
            if (stu != null && stu.getSid().equals(sid)){
                return true;
            }
        }
        return false;
    }

    //查看学生
    public Student[] findAllStudent() {
        Student[] stus = studentDao.findAllStudent();
        for (int i = 0; i < stus.length; i++) {
            Student stu = stus[i];
            if (stu != null) {
                return stus;
            }
        }
        return null;
    }

    //删除学生
    public void deleteStudent(String sid) {
        studentDao.deleteStudent(sid);
    }

    //修改学生
    public void updateStudent(String sid, Student student) {
studentDao.updateStudent(sid,student);
    }
}
